package logic

import (
	"context"
	"order_rpc/pkg"

	"order_rpc/internal/svc"
	"order_rpc/pb/order"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteOrderLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOrderLogic {
	return &DeleteOrderLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteOrderLogic) DeleteOrder(in *order.IDRequest) (*order.Empty, error) {
	err := l.svcCtx.OrderModel.UpdateStatus(l.ctx, in.OrderId, pkg.OrderStatusCancel)
	if err != nil {
		return nil, err
	}
	return &order.Empty{}, nil
}
